﻿using System;
using System.IO;
using EmbeddedSharp.Core;

namespace EmbeddedSharp.Scripting.Function.IO {

    /// <summary>
    /// hasfile("c:\\hello.txt");
    /// </summary>
    public class FileExistNode : FuncNode {

        public FileExistNode()
            : base() {
            base.Value = "isFile";
        }

        public override object Evaluate() {
            if (Parameters.Count < 1) {
                return "usage: hasFile(fileName)";
            }

            return File.Exists(Parameters[0].Evaluate().ToString());
        }
    }
}
